/**
 * @page: 订单规则
 * @author:elelee
 */

import { Tabs } from "antd";
import React, { useState, useEffect } from "react";
import { useLocation } from "react-router-dom";
import TabIntelligentExpress from "./components/TabIntelligentExpress";
import TabIntelligentTag from "./components/TabIntelligentTag";
import TabOrderBaseConfig from "./components/TabOrderBaseConfig/index";
import TagAutomateReview from "./components/TagAutomateReview";
import TagIntelligentPackaging from "./components/TagIntelligentPackaging";
import { getSearchParamsObj } from "@/utils/utils.jsx";

const { TabPane } = Tabs;

const OrderRule = () => {
	const [tab, setTab] = useState("0");
	const location = useLocation();

	useEffect(() => {
		if (location.pathname == "/views/order/rule") {
			const urlParams = getSearchParamsObj(location.search);
			const { tab1, tab2 } = urlParams;
			setTab(tab1);
		}
	}, [location.pathname]);

	return (
		<div className="zjf-container-nof">
			<Tabs
				activeKey={tab}
				defaultActiveKey="0"
				onChange={val => {
					setTab(val);
				}}
			>
				<TabPane tab="订单基础设置" key="0">
					<TabOrderBaseConfig />
				</TabPane>
				<TabPane tab="智能标签" key="1">
					<TabIntelligentTag type={tab} />
				</TabPane>
				<TabPane tab="智能包装" key="2">
					<TagIntelligentPackaging type={tab} />
				</TabPane>
				<TabPane tab="智能快递" key="3">
					<TabIntelligentExpress type={tab} />
				</TabPane>
				<TabPane tab="自动审核" key="4">
					<TagAutomateReview type={tab} />
				</TabPane>
			</Tabs>
		</div>
	);
};

export default OrderRule;
